package com.atguigu.service.impl;

import com.atguigu.Bean.C_user;
import com.atguigu.dao.UserDao;
import com.atguigu.dao.impl.UserDaoImpl;
import com.atguigu.service.UserService;

public class UserServiceImpl implements UserService {
    private UserDao ud=new UserDaoImpl();
    @Override
    public void registUser(C_user user) {
        int i = ud.saceUser(user);
        if(i!=-1){
            System.out.println("注册成功");
        }
        else{
            System.out.println("注册失败");
        }
    }

    @Override
    public C_user login(C_user user) {
        C_user c_user = ud.queryUserByUsernameAndPassword(user.getUsername(), user.getPassword());
        if(c_user==null){
//            System.out.println("用户名或密码错误！");
        }
        return c_user;
    }

    @Override
    public boolean existsUsername(String username) {
        if(ud.queryUserByUsername(username)!=null){
            //不等于null说明查到，查到就不可用
            return true;
        }else{
            //等于null说明没查到，没查到就可用
            return false;
        }

    }
}
